package com.ykefu.assign.demo;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.charset.Charset;

/**
 * @author likai
 * @date 2020/4/17 14:02
 * @email likai@7moor..com
 * @desc
 */
public class DiscardClientHandler extends SimpleChannelInboundHandler {


    private static final Logger LOGGER = LoggerFactory.getLogger(DiscardClientHandler.class);

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
        if(msg instanceof ByteBuf){
            String s = ((ByteBuf) msg).toString(Charset.forName("utf-8"));
            LOGGER.info("接受到服务端的消息：{}",s);
        }
    }
}
